package GUI;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ChaPanel extends JPanel implements ActionListener {
    private ImageIcon imageIcon = Utilimg.getIcon("/img/buttonOff.jpg");
    private JButton chajButton;
    private Text2 frame;
    private JTextField jTextField = new JTextField();//将组件作为私有属性，被调用，就可以赋值

    public JTextField getjTextField() {
        return jTextField;
    }

    public void setjTextField(JTextField jTextField) {
        this.jTextField = jTextField;
    }

    public ImageIcon getImageIcon() {
        return imageIcon;
    }

    public void setImageIcon(ImageIcon imageIcon) {
        this.imageIcon = imageIcon;
    }

    public ChaPanel(Text2 frame) {
        this.frame = frame;
        this.setLayout(null);
        this.setOpaque(false);

        JLabel jLabel = new JLabel("余额:");
        jLabel.setBounds(200, 150, 100, 50);
        jLabel.setFont(new Font("宋体", Font.BOLD, 30));
        this.add(jLabel);


//        frame.setjTextField(new JTextField());
//        frame.getjTextField().setBounds(300, 160, 200, 30);
//        frame.getjTextField().setFont(new Font("宋体",Font.BOLD,30));
//        this.add(frame.getjTextField());
        jTextField.setFont(new Font("宋体",Font.BOLD,30));
        jTextField.setBounds(300, 160, 200, 30);
        this.add(jTextField);

        chajButton = new JButton(imageIcon);
        chajButton.setBounds(690, 250, 100, 50);
        this.add(chajButton);
        chajButton.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == chajButton) {
            frame.switchPanel("menu");
        }
    }
}
